import request from '@/config/axios'

// 菜单 VO
export interface MenuVO {
  id: number // 主键
  name: string // 菜单名称
  icon: string // 图标
  parentId: number // 上级菜单
  fullPath: string // 完整全路径
}

// 菜单 API
export const MenuApi = {
  // 查询菜单列表
  getMenuList: async (params) => {
    return await request.get({ url: `/cms/menu/list`, params })
  },

  // 查询菜单详情
  getMenu: async (id: number) => {
    return await request.get({ url: `/cms/menu/get?id=` + id })
  },

  // 新增菜单
  createMenu: async (data: MenuVO) => {
    return await request.post({ url: `/cms/menu/create`, data })
  },

  // 修改菜单
  updateMenu: async (data: MenuVO) => {
    return await request.put({ url: `/cms/menu/update`, data })
  },

  // 删除菜单
  deleteMenu: async (id: number) => {
    return await request.delete({ url: `/cms/menu/delete?id=` + id })
  },

  // 导出菜单 Excel
  exportMenu: async (params) => {
    return await request.download({ url: `/cms/menu/export-excel`, params })
  },
}